using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 移动组件
/// </summary>
[DisallowMultipleComponent]
[RequireComponent(typeof(BoxCollider2D))]
public class MoveComponent : MonoBehaviour
{
    public float BaseSpeed { get; private set; }

    public float Speed { get; private set; }
    
    public float MoveSpeed => Speed;

    public void Initialize(float speed)
    {
        BaseSpeed = speed;
        Speed = speed;
    }

    public void Apply(float speed)
    {
        Speed = speed;
    }

    /// <summary>
    /// 设置移动速度
    /// </summary>
    /// <param name="speed">新的速度值</param>
    public void SetSpeed(float speed)
    {
        Speed = speed;
        Logger.Log("MoveComponent", $"当前速度:{speed}");
    }

    /// <summary>
    /// 重置为基础速度
    /// </summary>
    public void ResetToBaseSpeed()
    {
        Speed = BaseSpeed;
    }

    private void Update()
    {
        //移动
    }
}